<!DOCTYPE html>
<html>
<head>
    <title>模块配置</title>
    <include file='public/head'>
        <style>
            .layui-width-100{width: 100px !important;}
            .layui-legend-size{font-size:14px !important;}
            .layui-nopadding{padding:0 !important;}
            .layui-nomargin{margin: 0 !important;}
            .layui-bottom{
                border-width: 0 0 1px 0;
                border-style: solid;
                border-color: rgb(226, 226, 226);
            }
            .layui-input{height:30px !important; }
            .layui-top-margin{margin: 2px 0;}
            .layui-left-margin{margin-left: 10px;}
            .layui-table-page {padding: 7px 0px 0px;}
            .layui-table td, .layui-table th{
                padding:9px 5px;
            }
        </style>
</head>
<body>
<!-- layui-tab开始 -->
<div class="layui-tab " lay-filter="demo-tab">
    <!-- 顶部导航菜单开始 -->
    <div class="layui-tab-nav" >
        <ul class="layui-tab-title">
            <php> $currentTab = 3 ; </php>

    <li  style="padding: 0;" <?php if( $currentTab== 2 ) echo 'class="layui-this"' ; ?> ><a  style="padding:0 15px;" href="{:cmf_plugin_url('ModuleConfig://PluginList/index')}?name={$data.name}&store_id={$data.store_id}&file_name={$data.file_name}">插件列表</a></li>
    <li style="padding: 0;" <?php if( $currentTab== 3 ) echo 'class="layui-this"' ; ?> ><a style="padding:0 15px;" href="{:cmf_plugin_url('ModuleConfig://TableConfig/index')}?name={$data.name}&store_id={$data.store_id}&file_name={$data.file_name}">模块配置</a></li>
    <li style="padding: 0;" <?php if( $currentTab== 5 ) echo 'class="layui-this"' ; ?> ><a style="padding:0 15px;" href="{:cmf_plugin_url('ModuleConfig://RelevanceConfig/index')}?name={$data.name}&store_id={$data.store_id}&file_name={$data.file_name}">关联配置</a></li>

        </ul>
    </div> 
    <fieldset class="layui-elem-field layui-field-title " style="border-width: 1px;padding-left: 10px;">
        <legend class="layui-legend-size">搜索</legend>
        <form class="layui-form table-bar" action="{:cmf_plugin_url('ModuleConfig://table_config/index')}" lay-filter="form-bar" id="search-form">
            <div class="layui-form-item" style="margin-bottom: 0px;">
                <label>模块名：</label>
                <div class="layui-inline ">
                    <div class="layui-input-inline " style="width: 100px;">
                        <select name="name_storeid" lay-filter="module_name" lay-search>
                            <foreach name="module_list" item="vo">
                                <option value="{$vo.name}|{$vo.store_id}" <?php if($vo['name'] == $data['name']){echo 'selected';}?>>{$vo.title}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <label>方法：</label>
                <div class="layui-inline ">
                    <div class="layui-input-inline "  >
                        <select name="file_name" lay-verify="" class="layui-input" id="file-li">
                            <foreach name="file_list" item="fl">
                                <option value="{$fl}" <?php if(isset($data['file_name']) && $fl == $data['file_name']){echo 'selected';}?>>{$fl}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn layui-btn-sm btn-submit" style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon" >&#xe642;</i>保存配置</button>
                </div>
            </div>
        </form>
    </fieldset>
    <form class="layui-form table-bar" action="" id="form">
        <div class="layui-collapse" style="margin-top:20px" id="header">
            <include file='public/scripts'>
            <?php $params = [ 'file_name' => $data['file_name'] , 'module_name' => $data['name'] , 'view'=> $view ]; ?>
            <hook name="addTagsHtml" param="$params">
        </div>
    </form>
    <div class="layui-inline" style="margin-top:20px">
        <button type="button" class="layui-btn layui-btn-sm btn-submit" style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon" >&#xe642;</i>保存配置</button>
    </div>
</div>
<include file='public/scripts'>
<script >
$(function(){
    var layer = layui.layer
    ,form = layui.form;
    //搜索框
    form.on('select(module_name)', function(obj){
        var module_name = obj.value;
        let url = "{:cmf_plugin_url('ModuleConfig://table_config/getFileName')}?module_name="+module_name;
        $.ajax({
            url:url,
            type:'post',
            success:function(data){
                if ( data.code == 1 ) {
                    var html = '';
                    $.each(data.data,function(k,v){
                        html += '<option value="'+v+'">'+v+'</option>';
                    })
                    $('#file-li').html(html);
                    form.render();
                } 
            },
            error:function(){
                layer.msg( '系统错误' , { time:1200 , icon:2 });
            }
        })
    });
    //提交保存
    $('.btn-submit').on('click',function(){
        let url = "{:cmf_plugin_url('ModuleConfig://table_config/saveConfig')}";
        $.ajax({
            url:url,
            type:'post',
            data:$('#form').serialize()+"&"+$('#search-form').serialize(),
            success:function(data){
                if (data.code == 1) {
                    layer.msg( data.msg , { time:1200 , icon:1 },function(){
                        window.location.reload();
                    });
                } else {
                    layer.msg( data.msg , { time:1200 , icon:2 });
                }
            },
            error:function(){
                layer.msg( '系统错误' , { time:1200 , icon:2 });
            }
        })
    })
});
</script>
</body>
</html>